import React, { Component } from 'react'
import ComSon from './ComSon'

export default class ComFather extends Component {
  constructor() {
    super();
    this.state = {
      val: 10000,
      showSon: true
    }
  }
  changeVal() {
    this.setState({
      val: '666',
      showSon: false // 隐藏子组件
    })
  }
  render() {
    return (
      <div>
        <p>我是父组件</p>
        <button onClick={()=>this.changeVal()}>更新父的state，子的props</button>
        {this.state.showSon?<ComSon val={this.state.val}></ComSon>:null}
      </div>
    )
  }
}
